package com.hao.state;
// 模拟延时,放大问题的发生性
public class TestSleep implements Runnable{
    private int ticketNums = 10;

    @Override
    public void run() {
        while (true){
            if (ticketNums<=0){
                break;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String name = Thread.currentThread().getName();
            System.out.println(name+"拿到了第"+ticketNums--+"张票");
        }
    }

    public static void main(String[] args) {
        TestSleep testSleep = new TestSleep();
        new Thread(testSleep,"世浩").start();
        new Thread(testSleep,"夏普").start();
        new Thread(testSleep,"应用").start();
    }
}
